#!/usr/bin/env bash
# 将执行目录移动到 当前文件所在目录
cd `dirname $0`

# 检查配置文件
if [ ! -f 'vpn.conf' ];then
    cp vpn.conf.example vpn.conf
fi
source ./vpn.conf

CONTAINER_NAME="vpn";

docker pull mobtitude/vpn-pptp
docker stop ${CONTAINER_NAME}
docker rm ${CONTAINER_NAME}
docker run -d --privileged \
    -p 1723:1723 \
    -v `pwd`/vpn.conf:/etc/ppp/chap-secrets \
    --name "${CONTAINER_NAME}" \
    --restart=on-failure:10 \
    mobtitude/vpn-pptp
docker start "${CONTAINER_NAME}"

cd -
